#include <ostream>
#include <string.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>

using namespace std;

class Computer{
public:

    static Computer* getInstance(){
        if(_pInstance==nullptr){
            _pInstance=new Computer();
        }
        return _pInstance;
    }

    static void destory(){
        if(_pInstance){
            delete _pInstance;
            _pInstance=nullptr;
        }
    }
    Computer(const Computer& rhs)=delete;
    
    //最好把赋值运算符函数也delete
    Computer &operator=(const Computer &rhs)  =delete;

   /* {
        _pInstance=rhs._pInstance;
        return *this;
    }
*/

private:
    Computer(){};
    static Computer *_pInstance;
};
Computer * Computer::_pInstance=nullptr;

class Apple{
public:
    static Apple & getInstanc(){
        static Apple apple;
        return apple;
    }  
    Apple(const Apple &rhs)=delete;
private:
    Apple(){};
};

void test(){
    Computer *com1=Computer::getInstance();
    Computer *comp2;
    cout<<com1<<endl; 
    cout<<comp2<<endl; 
    com1->destory();
    comp2->destory();
    //Computer::destory();
    
    // cout<<&Apple::getInstanc()<<endl;;
    //cout<<&Apple::getInstanc()<<endl;;
    
}

int main()
{
 test();
 return 0;
}

